package 贪心算法;

public class 跳跃游戏Ⅱ {
   static class Solution{
        public int cover(int[] nums){
            if (nums==null||nums.length==1||nums.length==0){
                return 0;
            }
            int count=0;
            int currcover = 0;
            int maxcover = 0;
            for (int i = 0; i < nums.length; i++) {
                maxcover = Math.max(maxcover,i+nums[i]);
              if (maxcover>=nums.length-1){
                  count++;
                  break;
              }
              if (i==currcover){
                  currcover = maxcover;
                  count++;
              }
            }
            return count;
        }
    }
}
